/*
 * @Date: 2025-07-29 23:21:41
 * @LastEditors: 贾二小 erxiao.jia@outlook.com
 * @LastEditTime: 2025-07-29 23:21:50
 * @FilePath: /admin-vue/src/locales/dayjs.ts
 */
import { locale } from 'dayjs'
import 'dayjs/locale/zh-cn'
import 'dayjs/locale/en'
import { localStg } from '@/utils/storage'

/**
 * Set dayjs locale
 *
 * @param lang
 */
export function setDayjsLocale(lang: App.I18n.LangType = 'zh-CN') {
  const localMap = {
    'zh-CN': 'zh-cn',
    'en-US': 'en',
  } satisfies Record<App.I18n.LangType, string>

  const l = lang || localStg.get('lang') || 'zh-CN'

  locale(localMap[l])
}
